# ---------------------------------------
# --- CNC Control
# --- LinuxCNC HAL configuration file
# ------

loadusr -Wn cnccontrol linuxcnchal_cnccontrol

# --- Device config ---
setp	cnccontrol.config.twohand			1 # "two-hand" button enabled?
setp	cnccontrol.config.debug				0 # Device debug (0=off, 1=on, 2=verbose)
setp	cnccontrol.config.debugperf			0 # Performance monitoring (0=off, 1=on)
setp	cnccontrol.config.usblogmsg			0 # Send device debug messages through USB

# --- Machine state ---
net	cncc-on		halui.machine.is-on		=> cnccontrol.machine.on
net	cncc-estop	halui.estop.is-activated	=> cnccontrol.machine.estop.active
net	cncc-jog	halui.mode.is-manual		=> cnccontrol.machine.mode.jog
net	cncc-mdi	halui.mode.is-mdi		=> cnccontrol.machine.mode.mdi
net	cncc-auto	halui.mode.is-auto		=> cnccontrol.machine.mode.auto

# --- Axis enable/disable ---
setp	cnccontrol.axis.x.enable			1
setp	cnccontrol.axis.y.enable			1
setp	cnccontrol.axis.z.enable			1
setp	cnccontrol.axis.u.enable			0
setp	cnccontrol.axis.v.enable			0
setp	cnccontrol.axis.w.enable			0
setp	cnccontrol.axis.a.enable			0
setp	cnccontrol.axis.b.enable			0
setp	cnccontrol.axis.c.enable			0

# --- Axis position feedback ---
net	cncc-xposma	halui.axis.x.pos-feedback	=> cnccontrol.axis.x.pos.machine-coords
net	cncc-xposus	halui.axis.x.pos-relative	=> cnccontrol.axis.x.pos.user-coords
net	cncc-yposma	halui.axis.y.pos-feedback	=> cnccontrol.axis.y.pos.machine-coords
net	cncc-yposus	halui.axis.y.pos-relative	=> cnccontrol.axis.y.pos.user-coords
net	cncc-zposma	halui.axis.z.pos-feedback	=> cnccontrol.axis.z.pos.machine-coords
net	cncc-zposus	halui.axis.z.pos-relative	=> cnccontrol.axis.z.pos.user-coords
# If more axes are enabled, connect pins here.

# --- Jogging ---
setp	cnccontrol.jog.velocity-rapid			60000	# "rapid" move velocity
setp	cnccontrol.jog.increment.0			0.001	# 1st selectable increment
setp	cnccontrol.jog.increment.1			0.01	# 2nd selectable increment
setp	cnccontrol.jog.increment.2			0.1	# 3rd selectable increment
setp	cnccontrol.jog.increment.3			0.0	# 4th selectable increment
setp	cnccontrol.jog.increment.4			0.0	# 5th selectable increment
setp	cnccontrol.jog.increment.5			0.0	# 6th selectable increment
net	cncc-jogvel	cnccontrol.jog.velocity		=> halui.axis.jog-speed
net	cncc-jogxp	cnccontrol.jog.x.plus		=> halui.axis.x.plus
net	cncc-jogxm	cnccontrol.jog.x.minus		=> halui.axis.x.minus
net	cncc-jogxinc	cnccontrol.jog.x.inc		=> halui.axis.x.increment
net	cncc-jogxincp	cnccontrol.jog.x.inc-plus	=> halui.axis.x.increment-plus
net	cncc-jogxincm	cnccontrol.jog.x.inc-minus	=> halui.axis.x.increment-minus
net	cncc-jogyp	cnccontrol.jog.y.plus		=> halui.axis.y.plus
net	cncc-jogym	cnccontrol.jog.y.minus		=> halui.axis.y.minus
net	cncc-jogyinc	cnccontrol.jog.y.inc		=> halui.axis.y.increment
net	cncc-jogyincp	cnccontrol.jog.y.inc-plus	=> halui.axis.y.increment-plus
net	cncc-jogyincm	cnccontrol.jog.y.inc-minus	=> halui.axis.y.increment-minus
net	cncc-jogzp	cnccontrol.jog.z.plus		=> halui.axis.z.plus
net	cncc-jogzm	cnccontrol.jog.z.minus		=> halui.axis.z.minus
net	cncc-jogzinc	cnccontrol.jog.z.inc		=> halui.axis.z.increment
net	cncc-jogzincp	cnccontrol.jog.z.inc-plus	=> halui.axis.z.increment-plus
net	cncc-jogzincm	cnccontrol.jog.z.inc-minus	=> halui.axis.z.increment-minus
# If more axes are enabled, connect pins here.

# --- Master spindle control ---
net	cncc-srunb	halui.spindle.0.runs-backward	=> cnccontrol.spindle.runs-bwd
net	cncc-srunf	halui.spindle.0.runs-forward	=> cnccontrol.spindle.runs-fwd
net	cncc-sfwd	cnccontrol.spindle.forward	=> halui.spindle.0.forward
net	cncc-srev	cnccontrol.spindle.reverse	=> halui.spindle.0.reverse
net	cncc-sstart	cnccontrol.spindle.start	=> halui.spindle.0.start
net	cncc-sstop	cnccontrol.spindle.stop		=> halui.spindle.0.stop

# --- Feed override ---
net	cncc-foscale	cnccontrol.feed-override.scale	=> halui.feed-override.scale
net	cncc-fodec	cnccontrol.feed-override.dec	=> halui.feed-override.decrease
net	cncc-foinc	cnccontrol.feed-override.inc	=> halui.feed-override.increase
net	cncc-foval	halui.feed-override.value	=> cnccontrol.feed-override.value
setp	cnccontrol.feed-override.max-value		1.2	# Feed override max (1.0 = 100%)
setp	cnccontrol.feed-override.min-value		0	# Feed override min

# --- Program control ---
net	cncc-pstop	cnccontrol.program.stop		=> halui.program.stop
